<template>
  <div>
    <el-form inline :model="queryData" ref="queryData" class="query-form">

      <el-form-item label="公司名称:" prop="name">
        <el-input v-model="queryData.name" placeholder="请输入" style="width: 200px" clearable
                  @clear="formClear('name')"/>
      </el-form-item>
      <el-form-item label="统一社会信用代码:" prop="creditCode">
        <el-input v-model="queryData.creditCode" placeholder="请输入" style="width: 200px" clearable
                  @clear="formClear('creditCode')"/>
      </el-form-item>

      <el-form-item label="法定代表人:" prop="legalPerson">
        <el-input v-model="queryData.legalPerson" placeholder="请输入" style="width: 200px" clearable
                  @clear="formClear('legalPerson')"/>
      </el-form-item>

      <el-form-item label="关联园区:" prop="gardenName">
        <el-input v-model="queryData.gardenName" placeholder="请输入" style="width: 200px" clearable
                  @clear="formClear('gardenName')"/>
      </el-form-item>

      <el-form-item label="法定代表人联系方式:" prop="phone">
        <el-input v-model="queryData.phone" placeholder="请输入" style="width: 200px" clearable
                  @clear="formClear('phone')"/>
      </el-form-item>

      <el-form-item label="运营人姓名:" prop="operateName">
        <el-input v-model="queryData.operateName" placeholder="请输入" style="width: 200px" clearable
                  @clear="formClear('operateName')"/>
      </el-form-item>

      <el-form-item label="运营人联系方式:" prop="operatePhone">
        <el-input v-model="queryData.operatePhone" placeholder="请输入" style="width: 200px" clearable
                  @clear="formClear('operatePhone')"/>
      </el-form-item>

      <el-form-item label="认证状态:" prop="checkStatus">
        <el-select v-model="queryData.checkStatus" placeholder="请选择" clearable @clear="formClear('checkStatus')" style="width: 200px">
          <el-option label="待审核" value="0"/>
          <el-option label="审核通过" value="1"/>
          <el-option label="拒绝" value="2"/>
        </el-select>
      </el-form-item>

      <el-form-item label="关联主账号:" prop="userId">
        <el-input type="number" v-model="queryData.userId" placeholder="请输入" style="width: 200px" clearable
                  @clear="formClear('userId')"/>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">查 询</el-button>
        <el-button @click="onReset">重 置</el-button>
        <!-- <el-button type="primary" @click="lookOverEvent(null)">新 增</el-button> -->
      </el-form-item>
    </el-form>
    <el-table :data="tableList" border style="width: 100%;">
      <el-table-column prop="id" label="ID" align="center" width="80"/>
      <el-table-column prop="name" label="公司名称" align="center" width="150" show-overflow-tooltip/>
      <el-table-column prop="creditCode" label="统一社会信用代码" align="center" width="130" show-overflow-tooltip/>
      <el-table-column prop="legalPerson" label="法定代表人" align="center" width="130" show-overflow-tooltip/>
      <el-table-column prop="phone" label="法定代表人联系方式" align="center" width="150" show-overflow-tooltip/>
      <el-table-column prop="operateName" label="运营人姓名" align="center" width="130"/>
      <el-table-column prop="operatePhone" label="运营人联系方式" align="center" width="130" show-overflow-tooltip/>
      <el-table-column prop="checkStatus" label="认证状态" align="center" width="130" :formatter="(row)=> checkStatusArr[row.checkStatus - 0]"/>
      <el-table-column prop="userId" label="关联主账号UID" align="center"/>
      <el-table-column prop="gardenName" label="关联园区名称" align="center" width="200" show-overflow-tooltip/>
      <el-table-column prop="signString" label="添加方式" align="center" />
      <el-table-column label="操作" align="center" width="100" fixed="right">
        <template slot-scope="{row}">
          <el-button type="text" @click="lookOverEvent(row)">详 情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <Paging v-model="queryData" @change="getRequest"></Paging>
  </div>
</template>

<script>
  import { mapGetters } from 'vuex'
  export default {
    computed: {
      ...mapGetters(['confirm'])
    },
    name: 'enterpriseHomeAudit',
    data() {
      return {
        checkStatusArr: ['待审核','审核通过','拒绝'],
        tableList: [],
        queryData: {
          checkStatus: null, // 认证状态：0待审核；1审核通过；2拒绝
          creditCode: null, // 统一社会信用代码/纳税人识别号/组织结构代码
          legalPerson: null, // 法人代表
          name: null, // 企业名称
          operateName: null, // 运营人姓名
          operatePhone: null, // 运营人联系电话)
          phone: null, // 企业联系电话，
          pageNum: 1,
          pageSize: 10,
          total: 0
        },
        entity: null,
        drawer: false
      }
    },
    beforeMount() {
      this.getRequest()
    },
    methods: {
      /**
       * 查看详情
       */
      lookOverEvent(row) {
        this.$router.push(`/enterpriseManage/enterpriseAuditDetail?detailId=${row?.id|| ''}&status=1`)
      },
      /**
       * 重置事件
       */
      onReset() {
        this.queryData.pageNum = 1
        this.queryData.province = null
        this.queryData.city = null
        this.queryData.county = null
        this.$refs['queryData'].resetFields()
        this.getRequest()
      },
      /**
       * 查询条件提交事件
       */
      onSubmit() {
        this.queryData.pageNum = 1
        this.getRequest()
      },
      /**
       * 列表请求事件
       */
      async getRequest() {
        const params = JSON.parse(JSON.stringify(this.queryData))
        const res = await this.$ajax.get('/enterprise/backstage/amendList', { params })
        this.queryData.total = res.total
        this.tableList = res.rows
      },
      /**
       * form-input 置空事件
       */
      formClear(key) {
        this.queryData[key] = null
        this.onSubmit()
      }
    }
  }
</script>

<style scoped>
::v-deep input::-webkit-outer-spin-button,
::v-deep input::-webkit-inner-spin-button {
  -webkit-appearance: none !important;
}
/deep/ input[type='number'] {
  -moz-appearance: textfield !important;
  }
</style>
